package 代码随想2._2链表;

/**
 * @author XXX
 * @date 2024-01-14 13:36
 */

/**
 * https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/
 */
public class _6链表相交 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode A = headA;
        ListNode B = headB;
        while (A != B){
            A = A!=null?A.next:headB;
            B =B!=null?B.next:headA;
        }
        return A;
    }
}
